<template>
  <div>
    <br/>
      <div>
        <el-button type="primary" style="margin-left: 800px" @click="tianjia()">新增远区（医院导航信息）</el-button>
      </div>
      <div>
          <el-table border :data="Data.slice((currentPage-1)*pagesize,currentPage*pagesize)" style="width: 100%">
              <el-table-column prop="campusName" label="院区" ></el-table-column>
              <el-table-column prop="campusAddress" label="地址" ></el-table-column>
              <el-table-column prop="campusPhone" label="电话" ></el-table-column>
              <el-table-column prop="busLine" label="公交"  ></el-table-column>
              <el-table-column prop="floor" label="科室"  ></el-table-column>
              <el-table-column prop="campusContent" label="院区内容"  ></el-table-column>
              <el-table-column prop="campusAbout" label="院区简介"  width="400" :show-overflow-tooltip="true"></el-table-column>
             <el-table-column label="操作" v-slot="a">
              <el-button type="primary" size="mini" @click="xiugai(a.row)">修改</el-button>
              <el-button type="primary" size="mini" @click="shanchu(a.row)">删除</el-button>
            </el-table-column> 
          </el-table>
          <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[3, 5, 7]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="Data.length">
        </el-pagination>
      </div>
      <div>
        <el-dialog title="是否删除" :visible.sync="delmtk" :model="del">
        <el-button type="primary" @click="delHospital()">确定</el-button>
        <el-button type="primary" @click="delmtk=false" >取消</el-button>
      </el-dialog>
      </div>
  </div>
</template>

<script>
export default {
    data(){
        return{
            Data:[],
            upd:{},
            delmtk:false,
            del:{},
            headertitle: "",
            centerDialogVisible:false,
            pagesize:3,
            currentPage:1,
        }
    },
    created(){
        this.findCampusAll()
    },
    methods:{
        findCampusAll(){
            this.$axios.get("/user/user/doctor/ren/findCampusAll").then(res=>{
                this.Data=res.data.data.list
            })
        },
        tianjia(){
            this.$router.push({ path: "/AddHospital" });
        },
        xiugai(row){
            console.log(row)
            this.$router.push({ path: "/UpdHospital",query: {row: row}});
            this.upd={...row}
        },
        shanchu(row){
            this.delmtk=true;
            this.del = { ...row };
        },
        delHospital(){
            this.$axios.post("/user/user/doctor/ren/delHospital",this.del).then(res=>{
            this.delmtk=false;
            this.findCampusAll();
        })
        },
         handleSizeChange(size) {
            this.pagesize = size;
        },
        handleCurrentChange(currentPage) {
                this.currentPage = currentPage;
      }
    }
}
</script>

<style>

</style>
